package com.easygoods.controller;

import com.bestvike.stone.spring.controller.BaseController;
import com.bestvike.stone.spring.rest.common.CommonResponse;
import com.bestvike.stone.spring.shiro.annotation.RequiresPermissions;
import com.easygoods.response.AdvertResponse;
import com.easygoods.response.AppBannerResponse;
import com.easygoods.service.AdvertService;
import com.easygoods.shiro.auth.UserPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by 许崇雷 on 2019-03-07.
 */
@RestController
@RequestMapping("/api/advert")
public class AdvertController extends BaseController {
    @Autowired
    private AdvertService advertService;

    //新增收货地址、寄件地址，根据地址类型来区分
    @RequiresPermissions(UserPermissions.BUY)
    @GetMapping("/getAdvert")
    public CommonResponse<AdvertResponse> addAddress() {
        final AdvertResponse advert = this.advertService.getCurrentAdvert();
        return CommonResponse.success(advert);
    }

    //获取 appBanner
    @RequiresPermissions(UserPermissions.BUY)
    @GetMapping("/getAppBanner")
    public CommonResponse<List<AppBannerResponse>> getAppBanner() {
        final List<AppBannerResponse> bannerList = this.advertService.getAppBanner();
        return CommonResponse.success(bannerList);
    }
}
